package apoc.core.plugin;

import java.util.Collection;
import java.util.HashMap;

import apoc.boosters.BoosterPlugin;
import apoc.c4.C4Plugin;
import apoc.crate.CratePlugin;
import apoc.medkit.MedKitPlugin;
import apoc.thirst.ThirstPlugin;
import apoc.torch.TorchPlugin;
import apoc.weapons.WeaponsPlugin;
import apoc.weight.WeightPlugin;

public class PluginManager
{

    private static PluginManager instance;
    private HashMap<String, ApocPlugin> plugins;

    static
    {
        addPlugin(new BoosterPlugin());
        addPlugin(new CratePlugin());
        addPlugin(new MedKitPlugin());
        addPlugin(new ThirstPlugin());
        addPlugin(new TorchPlugin());
        addPlugin(new WeaponsPlugin());
        addPlugin(new C4Plugin());
        addPlugin(new WeightPlugin());
        addPlugin(new WeaponsPlugin());
    }

    private PluginManager()
    {
        this.plugins = new HashMap<String, ApocPlugin>();
    }

    public static Collection<ApocPlugin> plugins()
    {
        return instance().plugins.values();
    }

    public static PluginManager instance()
    {
        if (instance == null)
            instance = new PluginManager();
        return instance;
    }

    public static void addPlugin(ApocPlugin plugin)
    {
        instance().plugins.put(plugin.getId(), plugin);
    }

}
